package day11;

import java.lang.reflect.Method;

/**
 * @author oldliu
 * @since 1.0
 */
public class CalcTest {
    public static void main(String[] args) throws Exception {
        Calc c = new Calc();
//        int add = c.add(10, 20);
//        System.out.println(add);

        Method add = c.getClass().getDeclaredMethod("takeaway", int.class, int.class);
        //有没有注解
        if(add.isAnnotationPresent(MyTest.class)){
            MyTest annotation = add.getAnnotation(MyTest.class);//获得了一个注解的对象。。。
            System.out.println(">>>>>"+annotation.before());
            Object rtn = add.invoke(c, 10, 20);
            System.out.println(rtn);
            System.out.println(">>>>>"+annotation.after());
        }else{
            System.out.println("方法上没有注解");
            Object rtn = add.invoke(c, 10, 20);
            System.out.println(rtn);
        }


    }
}
